<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>用户列表</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    </script>
    <script lang="javaScript">
        function delUser(userId) {
            $.ajax({
                type: "GET",
                url: "/user/delUser/" + userId,
                data: "",//不需要传入数据就没传
                success: function (result) {
                    window.location.reload();
                }
            });
        }

        function modifyUser(userId) {
            window.location.href = "/user/modifyUserPage/" + userId
        }
    </script>
</head>
<body>
<div align="center">
    <a href="/user/addUserPage">添加用户</a><br><br><br>
</div>
<table align="center">
    <tr>
        <td th:text="编号"></td>
        <td th:text="名称"></td>
        <td th:text="操作"></td>
    </tr>
    <tr th:each="user : ${users}">
        <td th:text="${user.id}"></td>
        <td th:text="${user.userName}"></td>
        <td>
            <button th:onclick="delUser([[${user.id}]]);">删除</button>
            <button th:onclick="modifyUser([[${user.id}]]);">编辑</button>
        </td>
    </tr>
</table>
</body>
</html>
